package chapter02
import scala.collection.mutable
object Test23_List4 {
  def main(args: Array[String]): Unit = {
    //可变类型的list ListBuffer
    val listBuffer = mutable.ListBuffer(1, 2, 3, 4, 5)
    //取值
    println(listBuffer(1))
    //修改值
    listBuffer(1) = 20
    println(listBuffer)
    listBuffer.update(1,30)
    println(listBuffer)
    //增加元素
    listBuffer.+=(20)
    listBuffer.append(50,30)
    listBuffer.insert(1,100,200)
    println(listBuffer)
    //减少元素
    listBuffer.remove(1,2)
    println(listBuffer)
    //遍历元素
    listBuffer.foreach(println(_))
  }
}
